
TRIGGER PROCEDURE FOR WRITE OF vfd_det OLD BUFFER OLD_vfd_det.


{mfdeclre.i }
define new shared work-table wf_old_vfd_det like vfd_det.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "vfd_det" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(vfd_det), input "vfd_det").

    if not can-find ( first dt_mstr where dt_table = "vfd_det" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_vfd_det ) then do:
        create wf_old_vfd_det.
        if recid(wf_old_vfd_det)= -1 then .
    end.
    
    buffer-copy old_vfd_det to wf_old_vfd_det no-error.

    for each dt_mstr no-lock where dt_table = "vfd_det" and dt_type = "MOD" :
    
        case dt_field :

            when "vfd_id" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_id, input vfd_det.vfd_id,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_group" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_group), input string(vfd_det.vfd_group),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_number" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_number), input string(vfd_det.vfd_number),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_part, input vfd_det.vfd_part,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_sub_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_sub_part, input vfd_det.vfd_sub_part,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_type, input vfd_det.vfd_type,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_status" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_status, input vfd_det.vfd_status,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_pm_code" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_pm_code, input vfd_det.vfd_pm_code,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_site" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_site, input vfd_det.vfd_site,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_req_site" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_req_site, input vfd_det.vfd_req_site,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_buyer" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_buyer, input vfd_det.vfd_buyer,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_req_buyer" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_req_buyer, input vfd_det.vfd_req_buyer,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_vend" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_vend, input vfd_det.vfd_vend,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_price" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_price), input string(vfd_det.vfd_price),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_rel_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_rel_date), input string(vfd_det.vfd_rel_date),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_due_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_due_date), input string(vfd_det.vfd_due_date),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_req" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_req), input string(vfd_det.vfd_qty_req),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_avail" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_avail), input string(vfd_det.vfd_qty_avail),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_stk" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_stk), input string(vfd_det.vfd_qty_stk),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_pod" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_pod), input string(vfd_det.vfd_qty_pod),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_demand" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_demand), input string(vfd_det.vfd_qty_demand),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_all_pct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_all_pct), input string(vfd_det.vfd_all_pct),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_all_pre" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_all_pre), input string(vfd_det.vfd_all_pre),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_all_eff" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_all_eff), input string(vfd_det.vfd_all_eff),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_qty_phantom" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_qty_phantom), input string(vfd_det.vfd_qty_phantom),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_sfty_stk" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd_sfty_stk), input string(vfd_det.vfd_sfty_stk),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_rsn_code" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_rsn_code, input vfd_det.vfd_rsn_code,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_reason" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_reason, input vfd_det.vfd_reason,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_rmks" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_rmks, input vfd_det.vfd_rmks,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd_curr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd_curr, input vfd_det.vfd_curr,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__chr01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd__chr01, input vfd_det.vfd__chr01,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__chr02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd__chr02, input vfd_det.vfd__chr02,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__chr03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd__chr03, input vfd_det.vfd__chr03,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__chr04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_vfd_det.vfd__chr04, input vfd_det.vfd__chr04,
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dec01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dec01), input string(vfd_det.vfd__dec01),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dec02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dec02), input string(vfd_det.vfd__dec02),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dec03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dec03), input string(vfd_det.vfd__dec03),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dec04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dec04), input string(vfd_det.vfd__dec04),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__int01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__int01), input string(vfd_det.vfd__int01),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__int02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__int02), input string(vfd_det.vfd__int02),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dte01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dte01), input string(vfd_det.vfd__dte01),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__dte02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__dte02), input string(vfd_det.vfd__dte02),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__log01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__log01), input string(vfd_det.vfd__log01),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").

            when "vfd__log02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_vfd_det.vfd__log02), input string(vfd_det.vfd__log02),
                    input recid(vfd_det), input vfd_det.vfd_id, input string(vfd_det.vfd_group), input string(vfd_det.vfd_number), input vfd_det.vfd_part,
                    input vfd_det.vfd_sub_part, input "", input "", input "").
        end.
        
    end.
end.

{hkdttrans.i}
